// src/services/role.ts
import { request } from '@umijs/max';

// 获取角色列表
export async function getRoleList(params: any) {
  return request('/best-live-boot/sys/role/list', {
    method: 'GET',
    params,
  });
}

// 删除单个角色
export async function deleteRole(params: { id: string }) {
  return request('/best-live-boot/sys/role/delete', {
    method: 'DELETE',
    params,
  });
}

// 批量删除角色
export async function deleteRoleBatch(params: { ids: string }) {
  return request('/best-live-boot/sys/role/deleteBatch', {
    method: 'DELETE',
    params,
  });
}

// 获取角色信息 (用于编辑/详情)
export async function getRoleInfo(id: string) {
  return request(`/best-live-boot/sys/role/queryById/${id}`, {
    method: 'GET',
  });
}

// 添加角色
export async function addRole(data: any) {
  return request('/best-live-boot/sys/role/add', {
    method: 'POST',
    data,
  });
}

// 编辑角色
export async function editRole(data: any) {
  return request('/best-live-boot/sys/role/edit', {
    method: 'PUT', // 或 POST，根据后端 API 调整
    data,
  });
}

// 获取所有角色 (通常用于下拉选择等)
export async function getAllRoles(params: any) {
  return request('/best-live-boot/sys/role/queryall', {
    method: 'GET',
    params,
  });
}

// 检查角色编码唯一性 (如果需要)
export async function checkRoleCode(data: {
  fieldVal: string;
  dataId?: string;
}) {
  return request('/best-live-boot/sys/role/checkCode', {
    method: 'POST',
    data,
  });
}

// 根据权限查询角色
export async function getRoleListByPermission(params: any) {
  return request('/best-live-boot/sys/role/queryRoleListByPermission', {
    method: 'GET',
    params,
  });
}